//
//  ImportSubscriptionsViewController.m
//  Feed Rider
//
//  Created by Adrian-Sergiu Nicuta on 22/10/11.
//  Copyright (c) 2011 Adrisen Technologies SPRL. All rights reserved.
//

#import "ImportSubscriptionsViewController.h"

@implementation ImportSubscriptionsViewController

@synthesize fetchedResultsController;
@synthesize emailAddress;
@synthesize password;
@synthesize delegate;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIBarButtonItem *saveBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(importFeeds:)];
    
    self.navigationItem.rightBarButtonItem = saveBtn;
    [saveBtn release];
}

- (void)importFeeds:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidUnload
{
    [self setEmailAddress:nil];
    [self setPassword:nil];
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

- (void)dealloc {
    [emailAddress release];
    [password release];
    [super dealloc];
}

- (IBAction)cancel:(id)sender 
{
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)import:(id)sender 
{
    [self dismissModalViewControllerAnimated:YES];
    
    [self.delegate importSubscriptionsViewController:self didEnterEmail:emailAddress.text andPassword:password.text];
}

@end
